package com.mxin.ui.list

enum class PageDataState(private val value:Int){

    Match(3),  // = pageSize
    Wrap(2),   // > 0  && < pageSize
    Empty(1),  // == 0
    Null(0)   // == null
    ;

    /**
     * return
     * true : 小于&等于 参数state
     * false: 大于
     */
    fun compare(state: PageDataState):Boolean{
        return this.value <= state.value
    }


    companion object{

        @JvmStatic
        fun convertState(pd:PageData<*>):PageDataState{
            val size = pd.data?.size ?: return Null
            return when {
                size ==0 -> Empty
                size < pd.getPageSize() -> Wrap
                else -> Match
            }
        }
    }

}